首页>代码>spring+spring mvc+mybatis开发的java客户关系管理系统,前端采用easyui编写>/ssm-crm-new - 副本/src/com/crm/controller/CustomerController.java
/** * */ package com.crm.controller; import java.util.List; import javax.annotation.Resource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import com.crm.model.Customer; import com.crm.model.easyui.DataGrid; import com.crm.model.easyui.Json; import com.crm.model.easyui.PageHelper; import com.crm.service.CustomerService; /** * @author zh */ @Controller public class CustomerController { private final Logger log = LoggerFactory.getLogger(CustomerController.class); @Resource private CustomerService customerService; /** * 跳转到客户表格页面 * @return */ @RequestMapping(value = "/customer/list",method = RequestMethod.GET) public String customerList(Model model) { return "crm/customer_list"; } /** * 表格 * @return */ @ResponseBody @RequestMapping(value="/customer/datagrid", method = RequestMethod.POST) public DataGrid datagrid(PageHelper page,Customer customer) { DataGrid dg = new DataGrid(); dg.setTotal(customerService.getDatagridTotal(customer)); List<Customer> list = customerService.datagridCustomer(page); dg.setRows(list); return dg; } /** * 新增 * @return */ @ResponseBody @RequestMapping(value = "/customer/add",method = RequestMethod.POST) public Json add(Customer customer) { Json j = new Json(); try { customerService.addCustomer(customer); j.setSuccess(true); j.setMsg("用户新增成功!"); j.setObj(customer); } catch (Exception e) { j.setMsg(e.getMessage()); } return j; } /** * 修改 * * @return */ @ResponseBody @RequestMapping(value = "/customer/edit",method = RequestMethod.POST) public Json editUser(Customer customer) { Json j = new Json(); log.debug("穿过来的用户ID为:"+customer.getId()); try { customerService.editCustomer(customer); j.setSuccess(true); j.setMsg("编辑成功!"); j.setObj(customer); } catch (Exception e) { j.setMsg(e.getMessage()); } return j; } /** * 删除某个 * @param out */ @ResponseBody @RequestMapping(value = "/customer/delete",method = RequestMethod.POST) public Json delete(Customer customer) { Json j = new Json(); log.debug("穿过来的用户ID为:"+customer.getId()); try { customerService.deleteCustomer(customer.getId()); j.setSuccess(true); j.setMsg("删除成功!"); } catch (Exception e) { j.setMsg(e.getMessage()); } return j; } }
最近下载更多
爱丽淇 LV5
3月18日
杨豫川 LV12
2023年5月31日
qq1061521319 LV4
2022年9月15日
wangyang520 LV6
2022年5月2日
crofsun LV8
2022年3月28日
543666826 LV33
2021年11月19日
cyrus6693 LV2
2021年10月25日
lironggang LV38
2021年8月31日
小安同学 LV7
2021年6月20日
wanglinddad LV55
2021年5月5日